<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
    <title>_盘点计划列表</title>
    
	
	<script type="text/javascript">
	    String.prototype.replaceAll = function(s1,s2) { 
		    return this.replace(new RegExp(s1,"gm"),s2); 
		};
		
	   var dataTables_plan;  //dataTables-盘点计划
	   var infos_stock='';
	   var infos_sku='';
	
       $(function() {
           var now = new Date();
		   var today=(now.getFullYear())+"/"+(now.getMonth()+1)+"/"+(now.getDate());    
		   $("#_dataRange").val(today+"-"+today);
		   $("#_dataRange").daterangepicker({format: 'YYYY/MM/DD'});
		   
		   $("#_dataRange_1").daterangepicker({format: 'YYYY/MM/DD'});
		   
		    //初始化dataTables-plan
	        dataTables_plan=$("#table_plan").dataTable({
	           "bServerSide":true,
	           "sAjaxSource":'${ctx}/checkPlan/bindData_plan',
	           "fnServerData": retrieveData_plan,
	           "bFilter": false,
	           "bSort": false,
	           "sZeroRecords": "查询无记录！",
	           "bProcessing": true,
	           "oLanguage": {
	               "sUrl": '${ctx}/static/v2/js/plugins/datatables/cn.txt'
	            },
	            "aoColumns": [ 
	                    {"mData": 'customerCode'},
	                    {"mData": 'warehouseCode'},
	                    {
	                      "mData": 'planType',
	                      "render": function (obj) {
	                         var planType=obj;
	                         if(planType=='change'){
	                           return "<font color=red>动碰盘点</font>";
	                         }else if(planType=='sku'){
	                           return "<font color=blue>按商品盘点</font>";
	                         }else if(planType=='stock'){
	                           return "<font color=green>按库区盘点</font>";
	                         }else if(planType=='customer'){
	                           return "<font color=black>按商家盘点</font>";
	                         }else{
	                           return "";
	                         }
	                      }
	                    },
	                    {"mData": 'planCode'},
	                    {
	                      "mData": 'createTime',
	                      "render": function (obj) {
	                         var time=obj.time;
	                         var date = new Date(time);
	                         return date.Format("yyyy-MM-dd hh:mm:ss");
	                      }
	                    },
	                     {"mData": 'creater.realname'},
	                    {
	                      "mData": 'status',
	                      "render": function (obj) {
	                         var status=obj;
	                         if(status=='1'){
	                           return "创建盘点计划";
	                         }else if(status=='2'){
	                           return "领取点数任务";
	                         }else if(status=='3'){
	                           return "点数任务完成";
	                         }else if(status=='4'){
	                           return "领取校对任务";
	                         }else if(status=='5'){
	                           return "<font color=green>校对任务完成</font>";
	                         }else{
	                           return "";
	                         }
	                      }
	                    },
	                    {
	                     "mData": 'id',
	                      "render": function (obj,type,full) {
	                         var temp="<a href='${ctx}/checkPlan/v2_toPlanDetail/"+full.id+"' target='_blank' class='btn btn-primary' >查看明细</a>";
	                         var status=full.status;
	                         if(status=='1'){
	                            temp+="<button class='btn btn-danger' onclick='delCheckPlan("+full.id+")'>取消任务</button>";
	                         }
	                         temp+="<a href='${ctx}/checkPlan/exportCheckPlanDetailExcel/"+full.planCode+"' class='btn btn-primary' >导出明细</a>";
	                         return temp;
	                      }
	                    }
	                    
	             ]
	        });
		 
       });
       
       
       
         //回调函数_待处理订单
		function retrieveData_plan( sSource, aoData, fnCallback ) {
		   //查询参数
		   var customerCode=$("#_customerCode").val();
		   aoData.push( { "name": "customerCode", "value": customerCode } );  
		    
		   var warehouseCode=$("#_warehouseCode").val();
		   aoData.push( { "name": "warehouseCode", "value": warehouseCode } );
		   
		   var dataRange=$("#_dataRange").val();
		   aoData.push( { "name": "dataRange", "value": dataRange } );
		   
		   var status=$("#_status").val().trim();
		   aoData.push( { "name": "status", "value": status } );
		   
		   $.ajax({ 
		       "type": "post",
		       "contentType": "application/json", 
		       "url": sSource,    
		       "dataType": "json",   
		       "data": JSON.stringify(aoData),
		       "success": function(resp) {  
		       			fnCallback(resp);
		       		}
		   });    
		}
       
	   
	   
	    //查询
		function query(){
		   dataTables_plan.fnDraw();
		}
	   
	  
	  //盘点类型选择事件
	  function planTypeChange(){
	         var planType=$("#planType").val();
	         if(planType=='change'){
	            $("#changeTable").css("display","");
	            $("#skuTable").css("display","none");
	            $("#stockTable").css("display","none");
	            $("#customerTable").css("display","none");
	         }
	         else if(planType=='sku'){
	            $("#changeTable").css("display","none");
	            $("#skuTable").css("display","");
	            $("#stockTable").css("display","none");
	            $("#customerTable").css("display","none");
	         }
	         else if(planType=='stock'){
		        $("#changeTable").css("display","none");
		        $("#skuTable").css("display","none");
		        $("#stockTable").css("display","");
		        $("#customerTable").css("display","none");
		     }
		     else if(planType=='customer'){
		            $("#changeTable").css("display","none");
		            $("#skuTable").css("display","none");
		            $("#stockTable").css("display","none");
		            $("#customerTable").css("display","");
		     }
	         else{
	            $("#changeTable").css("display","none");
	            $("#skuTable").css("display","none");
	            $("#stockTable").css("display","none");
	            $("#customerTable").css("display","none");
	         }
	  }
	  
	  //打开创建计划窗体
	  function openWindow(){
		   var now = new Date();
		   var today=(now.getFullYear())+"/"+(now.getMonth()+1)+"/"+(now.getDate());    
		   $("#_dataRange_1").val(today+"-"+today);
		   $("#_dataRange_1").daterangepicker({format: 'YYYY/MM/DD'});
		  
		  $("#planType").val("");
		  $("#customerCode_1").val("");
		  $("#warehouseCode_1").val("");
		  $("#customerCode_2").val("");
		  $("#warehouseCode_2").val("");
		  
		  $("#changeTable").css("display","none");
          $("#skuTable").css("display","none");
          $("#stockTable").css("display","none");
          $("#customerTable").css("display","none");
          
          $("#grid_1").html('');
          $("#grid_2").html('');
          $("#grid_3").html('');
	  }
	  
	  //异动查询
	  function query_change(){
		  $("#grid_1").html('');
		  
		  var customerCode=$("#customerCode_1").val();
		  if(customerCode==''){
			  alert("请选择商家...");
			  $("#customerCode_1").focus();
			  return;
		  }
		  
		  var warehouseCode=$("#warehouseCode_1").val();
		  if(warehouseCode==''){
			  alert("请选择仓库...");
			  $("#warehouseCode_1").focus();
			  return;
		  }
		  
		  var dataRange=$("#_dataRange_1").val();
		  $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxQueryChange',
				data : {
					customerCode:customerCode,
					warehouseCode:warehouseCode,
					dataRange:dataRange
				},
				dataType : 'json',
				success : function(data) {
					
					var changeInfoList=data.changeInfoList;
					var str="";
					$.each(changeInfoList,function(i,info){
						str+="<tr>";
						str+="<td>"+(i+1)+"</td>";
						str+="<td>"+(info.sku)+"</td>";
						str+="<td>"+(info.inNum)+"</td>";
						str+="<td>"+(info.outNum)+"</td>";
						str+="<td>"+(info.changeNum)+"</td>";
						str+="</tr>";
					});
					$("#grid_1").html(str);
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	  }
	  
	  //创建盘点计划
	  function mySubmit(){
	
	    var planType=$("#planType").val();
	    if(!planType){
	    	alert("请选择盘点类型...");
	    }else{
	    	showBg();
		    //动碰盘点计划
		    if(planType=="change"){
			   createPlan_change();    
		    }
		    
		    //按商品盘点计划
		    else if(planType=="sku"){
				 createPlan_sku();     
		    }
		    
		    //按stock盘点计划
		    else if(planType=="stock"){
				 createPlan_stock();     
		    }
		    
		    //按商家盘点计划
		    else if(planType=="customer"){
				 createPlan_customer();     
		    }
		    closeBg();
	    }
	    
	  }
	  
	  //创建动碰盘点计划
	  function createPlan_change(){
		  var customerCode=$("#customerCode_1").val();
		   if(customerCode==''){
			  alert("请选择商家...");
			  $("#customerCode_1").focus();
			  return;
		   }
		   var warehouseCode=$("#warehouseCode_1").val();
		   if(warehouseCode==''){
			  alert("请选择仓库...");
			  $("#warehouseCode_1").focus();
			  return;
		   }
		   
		   var dataRange=$("#_dataRange_1").val();
	     
	       $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxCreatePlanChange',
				async:false,
				data : {
					customerCode:customerCode,
					warehouseCode:warehouseCode,
					dataRange:dataRange
				},
				dataType : 'json',
				success : function(data) {
				   if(data==true){
				      window.alert("创建盘点计划成功！"); 
					  location.href='${ctx}/checkPlan/v2_toStockCheckPlanList';
				   }else{
				      alert("网络繁忙，请稍后重试...");
				   }
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	  }
	  
	//创建盘点计划-按商品
	function createPlan_sku(){
	      var customerCode=$("#customerCode_2").val();
	      if(customerCode==''){
			  alert("请选择商家...");
			  $("#customerCode_2").focus();
			  return;
		   }
	      
	      var warehouseCode=$("#warehouseCode_2").val();
	      if(warehouseCode==''){
			  alert("请选择仓库...");
			  $("#warehouseCode_2").focus();
			  return;
		   }
	      
	      if(infos_sku==""){
	         alert("请选择商品...");
	         return;
	      }
	      
	      $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxCreatePlanSku',
				data : {
					customerCode:customerCode,
					warehouseCode:warehouseCode,
					infos_sku:infos_sku
				},
				async:false,
				dataType : 'json',
				success : function(data) {
				   if(data==true){
				      window.alert("创建盘点计划成功！"); 
					  location.href='${ctx}/checkPlan/v2_toStockCheckPlanList';
				   }else{
				      alert("网络繁忙，请稍后重试...");
				   }
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	      
	  }
	  
	  
	 //查询商品
	 function queryGoods(){
       var customerCode=$("#customerCode_2").val();
	   if(customerCode==''){
		  alert("请选择商家...");
		  $("#customerCode_2").focus();
		  return;
	   }
	  
	   var warehouseCode=$("#warehouseCode_2").val();
	   if(warehouseCode==''){
		  alert("请选择仓库...");
		  $("#warehouseCode_2").focus();
		  return;
	   }
	   
	   var sku=$("#sku").val().trim();
	   
       $.ajax({
			type : 'post',
			url : '${ctx}/checkPlan/ajaxQueryGoods',
			data : {
			    customerCode:customerCode,
				warehouseCode:warehouseCode,
				sku:sku
			},
			dataType : 'json',
			success : function(data) {
				var goodsList = data.goodsList;
				$("#grid_2").html("");
				var str='';
				$.each(goodsList, function(i) {
				    var  goodsStock=goodsList[i];
				    var info=goodsStock.warehouseCode+"【paiu】"+goodsStock.customer.customerCode+"【paiu】"+goodsStock.sku;
				    var  exist_flag=false;
				    if(infos_sku.indexOf(info)!=-1){
				       exist_flag=true;
				    }
				    str +="<tr>";
					str += "<td>" + goodsStock.customer.customerName+ "</td>";
					str += "<td>" + goodsStock.warehouseCode + "</td>";
					str += "<td>" + goodsStock.sku + "</td>";
					str += "<td>" + goodsStock.salesNum + "</td>";
					if(exist_flag==true){
				      str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_sku'  onclick='check_sku(this);' checked=true></td>";
				    }else{
				      str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_sku'  onclick='check_sku(this);' ></td>";
				    }
					str +="</tr>";
				});
				$("#grid_2").html(str);
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
		}); 
	}
	
	//查询已选择的商品
	function querySelected(){
	
	   if(infos_sku.length<=0){
	     return ;
	   }
	  
	   var customerCode=$("#customerCode_2").val();
	   if(customerCode==''){
		  alert("请选择商家...");
		  $("#customerCode_2").focus();
		  return;
	   }
	  
	   var warehouseCode=$("#warehouseCode_2").val();
	   if(warehouseCode==''){
		  alert("请选择仓库...");
		  $("#warehouseCode_2").focus();
		  return;
	   }
	   
	   $.ajax({
	  		type : 'post',
	 		url : '${ctx}/checkPlan/ajaxGetSkuSelected',
	 		data : {
	 			infos_sku:infos_sku
	 		},
	 		dataType : 'json',
	 		success : function(data) {
	 		    $("#grid_2").html("");
	 			var goodsStockList = data.goodsStockList;
	 			
	 			var str='';
	 			$.each(goodsStockList, function(i) {
	 			    
	 			    var  goodsStock=goodsStockList[i];
	 			    var info=goodsStock.warehouseCode+"【paiu】"+goodsStock.customer.customerCode+"【paiu】"+goodsStock.sku;
	 			    
	 			    str +="<tr>";
	 				str += "<td>" + goodsStock.customer.customerName+ "</td>";
	 				str += "<td>" + goodsStock.warehouseCode + "</td>";
	 				str += "<td>" + goodsStock.sku + "</td>";
	 				str += "<td>" + goodsStock.salesNum + "</td>";
	 				str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_sku'  onclick='check_sku(this);' checked=true></td>";
	 				str +="</tr>";
	 				
	 			});
	 			
	 			$("#grid_2").html(str);
	 		},
	 		error : function() {
	 			alert("网络繁忙，请稍后重试...");
	 		}
	 }); 
	}
	
    function allCheck_sku() {
		 $("input[name='var_check_sku']").attr("checked", $("#var_allCheck_sku").is(":checked"));
		
		 if($("#var_allCheck_sku").is(":checked")){
		    $('input[name="var_check_sku"]:checked').each(function(){
		        var info=$(this).attr("id");
		        if(infos_sku.indexOf(info+"【;】")==-1){
		          infos_sku+=info+"【;】";
		         }
			});
		 }else{
		   infos_sku='';
		 }
	  }
     
	 function check_sku(element) {
	    var info=$(element).attr("id");
		if ($(element).is(":checked")) {       //选中
		   if(infos_sku.indexOf(info+"【;】")==-1){
			   infos_sku+=info+"【;】";
		    }
		} else {        //取消选中 
			infos_sku=infos_sku.replaceAll( (info+"【;】") , '' );         
			$("#var_allCheck_sku").attr("checked", false);
		}
	  }
	 
	 function allCheck_stock() {
		 $("input[name='var_check_stock']").attr("checked", $("#var_allCheck_stock").is(":checked"));
		
		 if($("#var_allCheck_stock").is(":checked")){
		    $('input[name="var_check_stock"]:checked').each(function(){
		        var info=$(this).attr("id");
		        if(infos_stock.indexOf(info+"【;】")==-1){
		        	infos_stock+=info+"【;】";
		         }
			});
		 }else{
			 infos_stock='';
		 }
	  }
     
	 function check_stock(element) {
	    var info=$(element).attr("id");
		if ($(element).is(":checked")) {       //选中
		   if(infos_stock.indexOf(info+"【;】")==-1){
		       infos_stock+=info+"【;】";
		    }
		} else {        //取消选中 
		    infos_stock=infos_stock.replaceAll( (info+"【;】") , '' );         
			$("#var_allCheck_stock").attr("checked", false);
		}
	  }
	 
	//查询商品
	 function queryStock(){
       var customerCode=$("#customerCode_3").val();
	   if(customerCode==''){
		  alert("请选择商家...");
		  $("#customerCode_3").focus();
		  return;
	   }
	  
	   var warehouseCode=$("#warehouseCode_3").val();
	   if(warehouseCode==''){
		  alert("请选择仓库...");
		  $("#warehouseCode_3").focus();
		  return;
	   }
	   
	   var stock=$("#stock").val().trim();
	   
       $.ajax({
			type : 'post',
			url : '${ctx}/checkPlan/ajaxQueryStock',
			data : {
			    customerCode:customerCode,
				warehouseCode:warehouseCode,
				stockCode:stock
			},
			dataType : 'json',
			success : function(data) {
				var stockList = data.stockList;
				$("#grid_3").html("");
				var str='';
				$.each(stockList, function(i) {
				    var  stock=stockList[i];
				    var info=stock.customer_code+"【paiu】"+stock.areagroup_code+"【paiu】"+stock.stock_code;
				    var  exist_flag=false;
				    if(infos_stock.indexOf(info)!=-1){
				       exist_flag=true;
				    }
				    str +="<tr>";
					str += "<td>" + stock.customer_code+"</td>";
					str += "<td>" + stock.areagroup_code + "</td>";
					str += "<td>" + stock.stock_code + "</td>";
					if(exist_flag==true){
				      str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_stock'  onclick='check_stock(this);' checked=true></td>";
				    }else{
				      str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_stock'  onclick='check_stock(this);' ></td>";
				    }
					str +="</tr>";
				});
				
				$("#grid_3").html(str);
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
		}); 
	}
	
	//查询已选择的商品
	function querySelected_stock(){
	  
	   var customerCode=$("#customerCode_3").val();
	   if(customerCode==''){
		  alert("请选择商家...");
		  $("#customerCode_3").focus();
		  return;
	   }
	  
	   var warehouseCode=$("#warehouseCode_3").val();
	   if(warehouseCode==''){
		  alert("请选择仓库...");
		  $("#warehouseCode_3").focus();
		  return;
	   }
	   
	   $.ajax({
	  		type : 'post',
	 		url : '${ctx}/checkPlan/ajaxGetStockSelected',
	 		data : {
	 			infos_stock:infos_stock
	 		},
	 		dataType : 'json',
	 		success : function(data) {
	 		    $("#grid_3").html("");
	 			var stockList = data.stockList;
	 			
	 			var str='';
	 			$.each(stockList, function(i) {
	 			    
	 			    var  stock=stockList[i];
	 			    var info=stock.customer_code+"【paiu】"+stock.areagroup_code+"【paiu】"+stock.stock_code;
	 			    
	 			    str +="<tr>";
	 				str += "<td>" + stock.customer_code+ "</td>";
	 				str += "<td>" + stock.areagroup_code + "</td>";
	 				str += "<td>" + stock.stock_code + "</td>";
	 				str += "<td style='text-align: center;'><input type='checkbox' id='"+info+"' name='var_check_stock'  onclick='check_stock(this);' checked=true></td>";
	 				str +="</tr>";
	 				
	 			});
	 			
	 			$("#grid_3").html(str);
	 		},
	 		error : function() {
	 			alert("网络繁忙，请稍后重试...");
	 		}
	 }); 
	}
	
	//创建盘点计划-按stock
	function createPlan_stock(){
	      var customerCode=$("#customerCode_3").val();
	      if(customerCode==''){
			  alert("请选择商家...");
			  $("#customerCode_3").focus();
			  return;
		   }
	      
	      var warehouseCode=$("#warehouseCode_3").val();
	      if(warehouseCode==''){
			  alert("请选择仓库...");
			  $("#warehouseCode_3").focus();
			  return;
		   }
	      
	      if(infos_stock==""){
	         alert("请选择库位...");
	         return;
	      }
	      
	      $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxCreatePlanStock',
				data : {
					customerCode:customerCode,
					warehouseCode:warehouseCode,
					infos_stock:infos_stock
				},
				async:false,
				dataType : 'json',
				success : function(data) {
				   if(data==true){
				      window.alert("创建盘点计划成功！"); 
					  location.href='${ctx}/checkPlan/v2_toStockCheckPlanList';
				   }else{
				      alert("网络繁忙，请稍后重试...");
				   }
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	  }
	  
	  
	 //创建盘点计划-按商家
	 function createPlan_customer(){
	      var customerCode=$("#customerCode_4").val();
	      if(customerCode==''){
			  alert("请选择商家...");
			  $("#customerCode_4").focus();
			  return;
		   }
	      
	      var warehouseCode=$("#warehouseCode_4").val();
	      if(warehouseCode==''){
			  alert("请选择仓库...");
			  $("#warehouseCode_4").focus();
			  return;
		   }
	      
	      
	      $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxCreatePlanCustomer',
				data : {
					customerCode:customerCode,
					warehouseCode:warehouseCode
				},
				async:false,
				dataType : 'json',
				success : function(data) {
				   if(data==true){
				      window.alert("创建盘点计划成功！"); 
					  location.href='${ctx}/checkPlan/v2_toStockCheckPlanList';
				   }else{
				      alert("网络繁忙，请稍后重试...");
				   }
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	      
	  }
	  
	  //删除盘点任务
	  function delCheckPlan(id){
	  
	       $.ajax({
				type : 'post',
				url : '${ctx}/checkPlan/ajaxDelCheckPlan',
				data : {
					planId:id
				},
				dataType : 'json',
				success : function(data) {
				
				   var msg=data.msg;
				   if(msg=='cannot'){
				      window.alert("已经进入盘点流程，不能取消此任务！"); 
				   }else if(msg=='success'){
				      window.alert("成功取消盘点任务！");
				      dataTables_plan.fnDraw(); 
				   }else{
				      alert("网络繁忙，请稍后重试...");
				   }
				   
				},
				error:function() {
					alert("网络繁忙，请稍后重试...");
				}
			}); 
	  
	  }
       
    </script>
</head>

<body>
<div id="fullbg"></div>
<div id="dialog">
	<div>
		<img src="${ctx }/static/022.gif"></img>
	</div>
</div>
<section class="content">

    <!-- 查询条件  start-->
   	<div class="row">
	<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary" >
			    
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
				</div>
				
				<div class="box-body">
				    
				    <!-- 第一行 -->
					<div class="form-group row">
					
						<div class="col-sm-3">
							<div class="input-group col-sm-12">
								<span class="input-group-text"> 商家名称： </span> 
								<select class="form-control required" id="_customerCode" onchange="ajaxAreaGroup(this,'_warehouseCode')">
									<option value=""></option>
									<c:forEach items="${customerList}" var="customer">
										<option value="${customer.customerCode}"
											<c:if test="${customerCode eq customer.customerCode}">selected=selected</c:if>>${customer.customerName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						
						<div class="col-sm-3">
							<div class="input-group col-sm-12">
								<span class="input-group-text"> 作业仓库： </span> 
								<select class="form-control span3" id="_warehouseCode" >
									<option value=""></option>
									<c:forEach items="${warehouseList}" var="warehouse">
										<option value="${warehouse.groupCode}" >${warehouse.groupName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						
						<div class="col-sm-3">
							<div class="input-group col-sm-12">
								<span class="input-group-text"> 计划状态： </span> 
								<select  name="_status"  id="_status" class="form-control span3">
									<option value=""    <c:if test="${status eq ''}">selected=selected</c:if> ></option>
								    <option value="1"   <c:if test="${status eq '1'}">selected=selected</c:if> >创建计划</option>
								    <option value="2"   <c:if test="${status eq '2'}">selected=selected</c:if> >领取点数任务</option>
								    <option value="3"   <c:if test="${status eq '3'}">selected=selected</c:if> >点数任务完成</option>
								    <option value="4"   <c:if test="${status eq '4'}">selected=selected</c:if> >领取校对任务</option>
								    <option value="5"   <c:if test="${status eq '5'}">selected=selected</c:if> >校对任务完成</option>
								</select>
							</div>
						</div>
						
					</div>

                    <!-- 第二行 -->
					<div class=" form-group row">

						<div class="col-sm-6">
							<div class="input-group col-sm-12">
								<span class="input-group-text"> 创建日期： </span>

								<div class="input-group">
									<div class="input-group-addon">
										<i class="fa fa-calendar"></i>
									</div>
									<input type="text" class="form-control pull-right" id="_dataRange" name="_dataRange" value="${param._fromDate}"/>
								</div>
								
							</div>
						</div>
						
						<div class="col-sm-6">
							<button class="btn btn-info" type="button" onclick="query();">搜索</button>
							<a href="#detail" role="button" data-toggle="modal"  class="btn btn-primary" onclick="openWindow();" >创建盘点计划</a>
						</div>
						
					</div>
					
				</div>

			</div>

	 </div>
	</div>
    <!-- 查询条件 end -->
    
    <!-- 查询结果 start -->
	<div class="form-group row" >
	<div class="col-md-12">
	
       <div class="box box-primary">
			 <div class="box-header"></div>
			 <div class="box-body table-responsive">
			     <table id="table_plan" class="table table-bordered table-striped">
			         <thead>
			             <tr>
			                <th style="width: 80px;">商家名称</th>
						    <th style="width: 80px;">作业仓库</th>
						    <th style="width: 80px;">盘点类型</th>
						    <th style="width: 80px;">计划编号</th>
							<th style="width: 150px;">创建时间</th>
							<th style="width: 100px;">创建人</th>
							<th style="width: 100px;">当前状态</th>
							<th >操作</th>
			             </tr>
			         </thead>
			     </table>
			 </div>
		 </div>
	
	</div>
	</div>
	
	<!-- 创建盘点计划 -------------------------------------------------------------------------------------------------->
	<div class="modal fade" id="detail">
	<div class="modal-dialog" style="width: 60%;">
	<div class="modal-content">
	 <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">创建盘点计划</h4>
      </div>
		<!-- 体 -->
		<div class="modal-body form-search" >
		
		   

		   
                 <div class="form-group row">
<div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 选择盘点类型： </span>
					  <select id="planType" name="planType"  class="form-control" onchange="planTypeChange();" ">
						<option value="" ></option> 
							<option value="change">动碰盘点</option>
							<option value="sku">按商品盘点</option>
							<option value="stock">按库位盘点</option>
							<option value="customer">按商家盘点</option>
					  </select>
                </div>
			</div>  </div>
		    
		    <!-- 动碰盘点 -->
		    
		      <div class="form-group row" style="display:none;" id="changeTable">
		    <div class="col-sm-12" > 
		     <div class="form-group row">
		    <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 商家： </span>
<select id="customerCode_1" name="customerCode_1" class="form-control" onchange="ajaxAreaGroup(this,'warehouseCode_1');">
					        <option value=""></option>
							<c:forEach items="${customerList}" var="customer">
								<option value="${customer.customerCode}" >${customer.customerName}</option>
							</c:forEach>
					</select> 
					</div>
					</div>
					 <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 仓库： </span>
  <select  name="warehouseCode_1"  id="warehouseCode_1" class="form-control">
						<option value=""></option>
						<c:forEach items="${warehouseList}" var="w">
						   <option value="${w.groupCode}" >${w.groupName}</option>
					   </c:forEach>
					</select>
					</div>
					</div>
					</div>
			  <div class="form-group row">
			 <div class="col-sm-6">
			 <div class="input-group col-sm-12">
<span class="input-group-text"> 时间： </span>
<input class="form-control" type="text" id="_dataRange_1" name="_dataRange_1" />
			 </div>
			</div>
			 <div class="col-sm-6"> <button type="button" onclick="query_change();"  class="btn btn-primary" >查询</button></div>
</div> 
			<table class="table table-striped table-bordered table-condensed" >
              	<tr>
				    <th>序号</th>
				    <th>SKU编码</th>
				    <th>入库数量</th>
				    <th >出库数量</th>
				    <th >变动数量</th>
				</tr>
				<tbody id="grid_1" ></tbody>
			  </table>
			  </div>
			  </div>  
		     
		    <!-- 按sku -->
		    <div class="form-group row" style="display:none;" id="skuTable" >
		    <div class="col-sm-12" >
		     <div class="form-group row">
		    <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 商家： </span>
      <select id="customerCode_2" class="form-control" name="customerCode_2"  onchange="ajaxAreaGroup(this,'warehouseCode_2');">
				          <option value=""></option>
				  		  <c:forEach items="${customerList}" var="customer">
								<option value="${customer.customerCode}" >${customer.customerName}</option>
						  </c:forEach>
				   </select> 
					</div>
					</div>
					 <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 仓库：  </span>
  <select  name="warehouseCode_2" class="form-control" id="warehouseCode_2" >
						<option value=""></option>
						<c:forEach items="${warehouseList}" var="w">
						   <option value="${w.groupCode}" >${w.groupName}</option>
					   </c:forEach>
					</select>
					</div>
					</div>
					</div>
			 <div class="form-group row">
			 <div class="col-sm-6">
			 <div class="input-group col-sm-12">
<span class="input-group-text"> SKU编码：  </span>
<input class="form-control" type="text"  id="sku" > 
			 </div>
			</div>
			 <div class="col-sm-6">
             <button type="button btn-primary" onclick="queryGoods();"   class="btn btn-primary">搜索</button>
				    <button type="button" onclick="querySelected();" class="btn btn-primary">已选择</button>
</div>
</div>  
			<table class="table table-striped table-bordered table-condensed" >
			 <tr>
				    <th >商家</th>
				    <th >仓库</th>
				    <th >SKU</th>
				    <th >现库存量</th>
				    <th style="width:40px; text-align: center;">
				      <input type="checkbox" name="var_allCheck_sku" id="var_allCheck_sku"  onclick="allCheck_sku();" />
				    </th>
				</tr>
				
				<tbody id="grid_2"></tbody>
			 </table>
			 </div> </div>
			 
			<!-- 按库位 -->
			   <div class="form-group row" style="display:none;" id="stockTable">
		         <div class="col-sm-12"  >
							<div class="form-group row">
								<div class="col-sm-6">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 商家： </span> 
                                         <select id="customerCode_3" class="form-control" name="customerCode_3"  onchange="ajaxAreaGroup(this,'warehouseCode_3');">
				          <option value=""></option>
				  		  <c:forEach items="${customerList}" var="customer">
								<option value="${customer.customerCode}" >${customer.customerName}</option>
						  </c:forEach>
				   </select> 
									</div>
								</div>
								<div class="col-sm-6">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 仓库： </span> 
										<select  name="warehouseCode_3"  id="warehouseCode_3"  class="form-control" >
						<option value=""></option>
						<c:forEach items="${warehouseList}" var="w">
						   <option value="${w.groupCode}" >${w.groupName}</option>
					   </c:forEach>
					</select>
									</div>
								</div>
							</div>
							<div class="form-group row">
								<div class="col-sm-6">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> stock编码： </span>
				 	                    <input type="text" class="form-control"  id="stock" >
									</div>
								</div>
								<div class="col-sm-6">
									 <button type="button" onclick="queryStock();"   class="btn btn-primary">搜索</button>
				                     <button type="button" onclick="querySelected_stock();" class="btn btn-primary">已选择</button>
								</div>
							</div>
							<table  class="table table-striped table-bordered table-condensed" >
			    				<tr>
				    <th >商家</th>
				    <th >仓库</th>
				    <th >库位</th>
				    <th style="width:40px; text-align: center;">
				      <input type="checkbox" name="var_allCheck_stock" id="var_allCheck_stock" onclick="allCheck_stock()" />
				    </th>
				</tr>
				
				<tbody id="grid_3">
				</tbody>
			 </table>
			 </div> </div>
			 
			<!-- 按商家 -->
			   <div class="form-group row" style="display:none;" id="customerTable">
		        <div class="col-sm-12"   > 
			     <div class="form-group row">
		    <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 商家： </span>
 <select id="customerCode_4" class="form-control" name="customerCode_4"  onchange="ajaxAreaGroup(this,'warehouseCode_4');">
					          <option value=""></option>
					  		  <c:forEach items="${customerList}" var="customer">
									<option value="${customer.customerCode}" >${customer.customerName}</option>
							  </c:forEach>
					   </select> 
					</div>
					</div>
					 <div class="col-sm-6">
<div class="input-group col-sm-12">
<span class="input-group-text"> 仓库：  </span>
   <select  name="warehouseCode_4"  id="warehouseCode_4" class="form-control">
							<option value=""></option>
							<c:forEach items="${warehouseList}" var="w">
							   <option value="${w.groupCode}" >${w.groupName}</option>
						   </c:forEach>
						</select>
					</div>
					</div>
					</div>
					
			 </div>
			</div>  </div>  
		 
		
		<!-- 尾 -->
		<div class="modal-footer">
			<input id="submit_btn" class="btn btn-primary"  type="button" value="创建计划" onclick="mySubmit();"/>&nbsp;	
			<input id="cancel_btn" class="btn" type="button" data-dismiss="modal" value="返回" />
		</div>
		
		
	  
	  </div>	
     </div>
     <!------------------------------------------------------------------------------------------------------------->
     
</section>     
</body>
</html>
